<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">click me</button>

    <script>

        var oBtn = document.getElementById('btn');
        oBtn.onclick = function(){
            setTimeout(function(){
                console.log(this);
            }, 1000);
        };


        function test(name, age){
            console.log(this, name, age);
        }

        window.test();


        var o1 = {
            name: 'lisi',
            age: 23
        }
        // call方法的作用，它的第1个参数用来改变方法中的this指向
        // test.call(o1, 'lisi', 23);
        // test.apply(o1, ['lisi', 23]);
        var fn = test.bind(o1, 'lisi', 23);
        fn();

        // test('lisi', 23);
    </script>
</body>
</html>